<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">

<head th:replace="index::head">

</head>

<body>
    <ul class="layui-nav" th:replace="index::nav">
    </ul>

    <div>
        <div style="text-align: center;background-color: #4191C2;color: white;height: 150px;">
            <h1 style="padding: 50px">工资管理</h1>
        </div>
    </div>

    <div class="layui-container">
        <div class="layui-card">
            <div class="layui-card-body">
                <div class="layui-row">
                    <form action="/salary/search" method="get">
                        <div class="layui-col-xs4">
                            <div class="layui-input-block">
                                <input type="text" name="keyword" value=""   placeholder="请输入名字"
                                    autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-col-xs2">
                            <button type="submit" class="layui-btn layui-btn-success">查询</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <table class="layui-table" lay-even lay-skin="line" lay-size="lg">
            <colgroup>
                <col width="150">
                <col>
            </colgroup>
            <thead>
                <tr>
                    <th>id</th>
                    <th>员工ID</th>
                    <th>基础工资</th>
                    <th>津贴</th>
                    <th>合计</th>
                    <th>月份说明</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <tr th:each="u:${salaries}">
                    <td th:text="${u.id}">1</td>
                    <td th:text="${u.userId}">木子</td>
                    <td th:text="${u.base}">1</td>
                    <td th:text="${u.bonus}">66666</td>
                    <td th:text="${u.total}">CEO</td>
                    <td th:text="${u.month}">user</td>
                    <td>
                        <button type="button" class="layui-btn layui-btn-warm" th:onclick="'update('+${u.id}+')'">编辑</button>
                        <button type="button" class="layui-btn layui-btn-danger" th:onclick="'del('+${u.id}+')'">删除</button>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</body>
<script>



    function update(id){
        window.location.href="/salary/edit/"+id
    }

    function del(id){
        $.get('/salary/remove/'+id,function(data){
            if(data.code===200){
                    layer.msg('删除成功！'); 
                    setTimeout(() => {
                        window.location.reload();
                    }, 1200);
                }
        })
    }
</script>
</html>